home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: Chris Torek <torek@elf.bsdi.com>
- Newsgroups: comp.std.c,comp.lang.c.moderated
- Subject: Re: Integral promotion.
- Date: 16 Feb 1996 09:23:03 -0600
- Organization: Berkeley Software Design, Inc.
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4g27gn$q5k@solutions.solon.com>
- References: <4fstj7$2l6@solutions.solon.com> <4fu835$9de@solutions.solon.com> <4fvgrm$dv9@solutions.solon.com>
- Reply-To: torek@bsdi.com
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4fvgrm$dv9@solutions.solon.com>, <msb@sq.com> wrote:
- >Oh dear, I have to correct Chris Torek (torek@bsdi.com).
-
- Heh... it happens, especially when I am in a hurry (as I was this time).
- You can usually tell a hurried article by its length: I need time to
- write a short one.
-
- >... If int and short are the same width, overflow can occur, with
- >undefined behavior. [But if int is wider than short, the sum is
- done in the wider precision and does not overflow, and then:]
-
- >Excerpts from the standard:
- >
- >* From 6.3.16.1/3.3.16.1:
- ># In "simple assignment" (=), the value of the right operand is
- ># converted to the type of the left operand ...
- >
- >* From 6.2.1.2/3.2.1.2:
- ># When a value with integral type is demoted to a signed integer with
- ># smaller size ... if the value cannot be represented the result is
- ># implementation-defined.
- >
- >Hence implementation-defined behavior occurs.
-
- Thus, the implementation has to say exactly how it handles this.
- There is still some question as to whether the implementation can
- define it as an overflow resulting in program termination, is there
- not?
- --
- In-Real-Life: Chris Torek, Berkeley Software Design Inc
- El Cerrito, CA Domain: torek@bsdi.com +1 510 234 3167
-